broad_dict = {'k_one': {'ID', 'NV', 'UT'}, 'k_two': {'WA', 'ID', 'MT'}, 'k_three': {'OR', 'NV', 'UT'}, 'k_four': {'NV', 'UT'}, 'k_five': {'CA', 'AZ'}}
zone = {'MT', 'WA', 'ID', 'OR', 'NV', 'UT', 'CA', 'AZ', '额外的没有任何覆盖的区域'}
broad_list = []
#
# def longest():
choosed = set()
choose_broad = set()
over = 1

# 这句写的循环退出条件是错的，因为如果之前执行过if并且pop了区域，下一次再执行时，不会执行if内语句，但是还会pop相同的区域，导致出错
# while choosed != zone and over == 1:

while choosed != zone:
    area = 0
    over = 0
    for k in broad_dict.items():
        if len(k[1] - choosed) > area:
            area = len(k[1]-choosed)
            choose_broad = k
            over = 1
    # 这句是为了判断是否执行了上面的if语句，如果没有执行，说明没有符合条件的项目就退出循环
    if over == 0:
        break
    broad_dict.pop(choose_broad[0])
    choosed = choosed | choose_broad[1]
    broad_list.append(choose_broad[0])
print(choosed)
print(broad_list)